package com.zkzx.company.api.controller.message;

import com.zkzx.common.message.command.MessageCommand;
import com.zkzx.common.message.model.MessageListVO;
import com.zkzx.common.vo.PageResult;
import com.zkzx.common.vo.RequestFilterParams;
import com.zkzx.company.api.controller.BaseController;
import com.zkzx.company.api.service.message.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 北京中科智兴物联科技有限公司 @版权所有
 *
 * @Author: zhaoyihe@zkraising.com
 * @Date: 2021/05/17/17:08
 * @Description:
 */
@RestController
@Validated
@Api( tags="消息管理")
@RequestMapping(value = "/messages")
public class MessageController extends BaseController {

    @Resource
    private MessageService messageService;


    @GetMapping
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "获取消息列表", notes = "获取消息列表")
    public PageResult<MessageListVO> find(@ApiParam(value = "分页查询参数") RequestFilterParams params )  {

        return messageService.find(params,super.getCompanyId());
    }

    /**
     * 查询未读站内信
     */
    @PutMapping("/reading")
    @ResponseStatus(HttpStatus.OK)
    @ApiOperation(value = "全部已读", notes = "全部已读")
    public void reading( @RequestBody @Valid MessageCommand command) {
        messageService.reading(command,super.getUserId(),super.getCompanyId());
    }


}
